V33-a
authorjoan <joan@abyz.co.uk>
Mon, 1 Jun 2015 17:32:03 +0000 (18:32 +0100)
committerjoan <joan@abyz.co.uk>
Mon, 1 Jun 2015 17:32:03 +0000 (18:32 +0100)
pigpio.c
pigpio.h
pigpio.py
pigs.c
setup.py
x_pigpio.py

index 5b127e5341fb9df743367b2b80b2baed83e98f2a..9725ecdd355f15264205caed75db5f9ce53bc1b0 100644 (file)
--- a/pigpio.c
+++ b/pigpio.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 For more information, please refer to <http://unlicense.org/>
 */
 
-/* pigpio version 33 */
+/* pigpio version 34 */
 
 /* include ------------------------------------------------------- */
 
index 2ee56842c9acf1703b62b27e12e6470b7228190d..25fd7582b93c63d9f7e619e200d3330281a27226 100644 (file)
--- a/pigpio.h
+++ b/pigpio.h
@@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
 #include <stdint.h>
 #include <pthread.h>
 
-#define PIGPIO_VERSION 33
+#define PIGPIO_VERSION 34
 
 /*TEXT
 
@@ -1956,7 +1956,7 @@ D*/
 int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal);
 /*D
 This writes 16 bits of data to the specified register of the device
-associated with handle and and reads 16 bits of data in return.
+associated with handle and reads 16 bits of data in return.
 
 . .
 handle: >=0, as returned by a call to [*i2cOpen*]
@@ -3742,7 +3742,7 @@ samples per second.
 
 cfgMillis:: 100-10000
 
-The size of the sample buffer in milliseconds.  Gnerally this should be
+The size of the sample buffer in milliseconds.  Generally this should be
 left at the default of 120ms.  If you expect intense bursts of signals it
 might be necessary to increase the buffer size.
 
@@ -4063,7 +4063,7 @@ The number of segments in a combined I2C transaction.
 
 offset::
 The associated data starts this number of microseconds from the start of
-tghe waveform.
+the waveform.
 
 *outBuf::
 A buffer used to return data from a function.
index 39742726b7724db5e70154d2388a9997422ad71d..449267156fabddcb01e926bbf8244f9f620c952a 100644 (file)
--- a/pigpio.py
+++ b/pigpio.py
@@ -263,7 +263,7 @@ import threading
 import os
 import atexit
 
-VERSION = "1.18"
+VERSION = "1.19"
 
 exceptions = True
 
diff --git a/pigs.c b/pigs.c
index cc6876c249ad2be1eb94715dadea32d8981e658c..b97418b6e211d60c2dbc0de5a8a9b5c1c7021f40 100644 (file)
--- a/pigs.c
+++ b/pigs.c
@@ -33,6 +33,7 @@ This version is for pigpio version 33+
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
+#include <ctype.h>
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -50,8 +51,13 @@ the commands available from pigpio.
 char command_buf[8192];
 char response_buf[8192];
 
+int printFlags = 0;
+
 #define SOCKET_OPEN_FAILED -1
 
+#define PRINT_HEX 1
+#define PRINT_ASCII 2
+
 void fatal(char *fmt, ...)
 {
    char buf[128];
@@ -66,6 +72,30 @@ void fatal(char *fmt, ...)
    fflush(stderr);
 }
 
+static int initOpts(int argc, char *argv[])
+{
+   int opt, args;
+
+   args = 1;
+
+   while ((opt = getopt(argc, argv, "ax")) != -1)
+   {
+      switch (opt)
+      {
+         case 'a':
+            printFlags |= PRINT_ASCII;
+            args++;
+            break;
+
+         case 'x':
+            printFlags |= PRINT_HEX;
+            args++;
+            break;
+        }
+    }
+   return args;
+}
+
 static int openSocket(void)
 {
    int sock, err;
@@ -108,7 +138,7 @@ static int openSocket(void)
 
 void print_result(int sock, int rv, cmdCmd_t cmd)
 {
-   int i, r;
+   int i, r, ch;
    uint32_t *p;
 
    r = cmd.res;
@@ -146,9 +176,20 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
          if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
          if (r > 0)
          {
+            if (printFlags == PRINT_ASCII) printf(" ");
+
             for (i=0; i<r; i++)
             {
-               printf(" %hhu", response_buf[i]);
+               ch = response_buf[i];
+
+               if (printFlags & PRINT_HEX) printf(" %hhx", ch);
+
+               else if (printFlags & PRINT_ASCII)
+               {
+                  if ((ch > 31) && (ch < 127)) printf("%c", ch);
+                  else printf("\\x%02hhx", ch);
+               }
+               else printf(" %hhu", response_buf[i]);
             }
          }
          printf("\n");
@@ -203,7 +244,7 @@ void get_extensions(int sock, int command, int res)
 int main(int argc , char *argv[])
 {
    int sock, command;
-   int idx, i, pp, l, len;
+   int args, idx, i, pp, l, len;
    cmdCmd_t cmd;
    uint32_t p[CMD_P_ARR];
    cmdCtlParse_t ctl;
@@ -212,11 +253,13 @@ int main(int argc , char *argv[])
 
    sock = openSocket();
 
+   args = initOpts(argc, argv);
+
    command_buf[0] = 0;
    l = 0;
    pp = 0;
 
-   for (i=1; i<argc; i++)
+   for (i=args; i<argc; i++)
    {
       l += (strlen(argv[i]) + 1);
       if (l < sizeof(command_buf))
index 0f3a7cc435256b8eee39c881556228ffadf280ff..995ad323c5bd60bc491ae266e8f9ecbf4819cdc0 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
 from distutils.core import setup
 
 setup(name='pigpio',
-      version='1.18',
+      version='1.19',
       author='joan',
       author_email='joan@abyz.co.uk',
       maintainer='joan',
index 0faa461fe573274df398df06f52cecee04865c34..e0439b6d55904ed497eb8cf126479efa1add8cbc 100755 (executable)
@@ -384,8 +384,8 @@ To the lascivious pleasing of a lute.
 
    oc = t5_count
    while pi.wave_tx_busy():
-      time.sleep(0.1)
-   time.sleep(0.1)
+      time.sleep(0.2)
+   time.sleep(0.2)
    c = t5_count - oc
    CHECK(5, 10, c, 1702, 0, "wave tx busy, callback")
 
@@ -455,8 +455,8 @@ To the lascivious pleasing of a lute.
 
    oc = t5_count
    while pi.wave_tx_busy():
-      time.sleep(0.1)
-   time.sleep(0.1)
+      time.sleep(0.2)
+   time.sleep(0.2)
    c = t5_count - oc
    CHECK(5, 32, c, 1702, 0, "wave tx busy, callback")